package com.tengju.user.domain.model.user;

import com.tengju.user.domain.model.login.UserType;
import lombok.Value;
import lombok.experimental.NonFinal;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author wuziyang
 */
@Value
public class Staff implements LoginDesc, Serializable {

    /**
     * 员工id
     */
    private StaffId staffId;

    /**
     * 姓名
     */
    private String name;

    /**
     * 头像
     */
    @NonFinal
    private String headImage;

    /**
     * 创建人
     */
    @NonFinal
    private String createBy;

    /**
     * 创建时间
     */
    @NonFinal
    private LocalDateTime createTime;

    /**
     * 修改人
     */
    @NonFinal
    private String updateBy;

    /**
     * 修改时间
     */
    @NonFinal
    private LocalDateTime updateTime;

    public Staff(StaffId staffId, String name, String headImage, String createBy, LocalDateTime createTime, String updateBy, LocalDateTime updateTime) {
        this.staffId = staffId;
        this.name = name;
        this.headImage = headImage;
        this.createBy = createBy;
        this.createTime = createTime;
        this.updateBy = updateBy;
        this.updateTime = updateTime;
    }

    public Staff(StaffId staffId, String name) {
        this.staffId = staffId;
        this.name = name;
    }

    @Override
    public long getId() {
        return staffId.getValue();
    }

    @Override
    public String getNickName() {
        return name;
    }

    @Override
    public UserType getUserType() {
        return UserType.STAFF;
    }

    @Override
    public UserIdCode getUserIdCode() {
        return null;
    }


    public static Staff getAdminStaff() {
        return new Staff(
                new StaffId(9999999),
                "admin"
        );
    }
}
